package DigitalNetwork;

import java.awt.Color;
import java.awt.Graphics;

public class LEDView extends UnitView {

    /** [Konstruktor]
     * Hozzaadja a Unitot a View-hoz.
     */
	//==========================================================================
    public LEDView(Unit u){
        super(u);
    }
    //==========================================================================

	/**
	 * 
	 * @param g
	 * @return 
	 */
    @Override
	public void draw(Graphics g) {
		// A tartalmazott Unit kasztolasa LED-re
        LED l = (LED)this.unit;

        // Keret es UnitID szine
        g.setColor(Color.BLACK);

        // Keret kirajzolasa
        g.drawRoundRect(0, 0, NetworkView.UNIT_SIZE, NetworkView.UNIT_SIZE, 20, 20);
        g.drawString(l.getID(), 2, NetworkView.UNIT_SIZE/2 + 5 );

        // LED ertekenek szine (1 - zold | 0 - piros)
        if(l.getState()){
            g.setColor(Color.GREEN);
        } else {
            g.setColor(Color.RED);
        }

        // LED ertekenek kirajzolasa
        g.drawString(l.getState() ? "[1]" : "[0]", NetworkView.UNIT_SIZE - 15, NetworkView.UNIT_SIZE/2 + 5 );
	}

}